var count = 0;
$("#ensure").click(function () {//同意
    count++;
    var oneChannel = $("#oneChannel").val();       //一级渠道
    var twoChannel = $("#twoChannel").val();       //二级渠道
    var thrChannel = $("#thrChannel").val();       //三级渠道
    var remarks = $("#remarks").val();             //备注
    var outpatientName = $("#outpatientNameValue").val();             //门诊
    var reservationsId = $("#reservationsId").val();
    var customerName = $("#customerName").val();
    var customerPhone = $("#customerPhone").val();
    var id = $("#idValue").val();
    var archiving = $("#archiving").val();
    var xfollower = $("#xfollower").val();            //建档人
    var xbelonger = $("#xbelonger").val();            //新归属人
    if (count == 1) {
        $.ajax({
            url: Feng.ctxPath + "/reservations/updateModity1",
            type: "post",
            data: {
                reservationsId: reservationsId, id: id, xfollower: xfollower, xbelonger: xbelonger,
                oneChannel: oneChannel, twoChannel: twoChannel, outpatientName: outpatientName,
                thrChannel: thrChannel,
                customerName: customerName, customerPhone: customerPhone, archiving: archiving,
                remarks: remarks
            },
            success: function (data) {
                Feng.success('操作成功!');
                window.parent.ApprovalProcess.table.refresh();
                $("#cancel").click();
            },
            error: function (data) {
                count=0;
                alert('没有权限，请联系系统管理员!');
                window.parent.ApprovalProcess.table.refresh();
                $("#cancel").click();
            }
        });
    } else {
        count=0;
        window.parent.ApprovalProcess.table.refresh();
        $("#cancel").click();
    }
});

$("#refuse").click(function () {//拒绝
    count++;
    var remarks = $("#remarks").val();             //备注
    var outpatientName = $("#outpatientNameValue").val();             //门诊
    var reservationsId = $("#reservationsId").val();
    var customerName = $("#customerName").val();
    var customerPhone = $("#customerPhone").val();
    var id = $("#idValue").val();
    var name = $("#name").val();
    if (count == 1) {
        $.ajax({
            url: Feng.ctxPath + "/reservations/updateModity3",
            type: "post",
            data: {
                reservationsId: reservationsId, id: id, remarks: remarks, outpatientName: outpatientName,
                customerName: customerName, customerPhone: customerPhone, archiving: name
            },
            success: function (data) {
                Feng.success('操作成功!');
                window.parent.ApprovalProcess.table.refresh();
                $("#cancel").click();
            },
            error: function (data) {
                alert('没有权限，请联系系统管理员!');
                $("#cancel").click();
            }
        });
    } else {
        count=0;
        window.parent.ApprovalProcess.table.refresh();
        $("#cancel").click();
    }
});

$("#cancel").click(function () {
    parent.layer.close(parent.layer.getFrameIndex(window.name));
});